<h2>Edit base permissions for role '<?php echo $role->name; ?>'</h2>

<?php if(Yii::app()->user->hasFlash('permissionsSaved')): ?>

<div class="info"><?php echo Yii::app()->user->getFlash('permissionsSaved'); ?></div>
<?php Yii::app()->clientScript->registerScript(
   'myHideEffect',
   '$(".info").animate({opacity: 1.0}, 3000).fadeOut("slow");',
   CClientScript::POS_READY
);
?>
<?php endif; ?>

<div class="form">
<?php echo CHtml::errorSummary($role); ?>

<?php echo CHtml::beginForm(); ?>

<table class="dataGrid">
  <tr>
    <th>Allow</th>
    <th>Controller / Action</th>
    <th>Description</th>
  </tr>
<?php foreach($perms as $n => $perm): ?>
	<?php if ($perm['tunable'] == 'no') continue; ?>
	<tr class="<?php echo (($n & 1) == 0) ? 'even' : 'odd' ; ?>">
		<td><input type="checkbox" id="<?php echo $perm['id']; ?>" name="RolePermissions[<?php echo $perm['id']; ?>]"
				   <?php echo ($role->base_permissions & (1 << $perm['id'])) ? 'checked': ''; ?> /></td>
		<td class="left"><?php echo $perm['controller'].' / '.$perm['action']; ?></td>
		<td class="left"><?php echo $perm['description']; ?></td>
	</tr>
<?php endforeach; ?>

</table>
<div class="row">
<?php echo CHtml::submitButton('Save', array('name'=>'submitRolePermissions')); ?>
</div>

<?php echo CHtml::endForm(); ?>
</div>